package com.gitee.feizns.explore.data_structure.visual.frame.test;

import com.gitee.feizns.explore.data_structure.visual.frame.Utils;

import javax.swing.*;
import java.awt.*;

/**
 * @author feizns
 * @since 2019/12/31
 */
public class AlgoFrame extends JFrame {

    public static void main(String[] args) {
        EventQueue.invokeLater(() -> {
            AlgoFrame frame = new AlgoFrame();
            frame.start();
        });
    }

    public AlgoFrame(String title, int weight, int height) {
        super(title);
        setSize(weight, height);
        setContentPane(new AlgoPanel());
        setResizable(false);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setVisible(true);
        setLocation(new Point(200, 200));
    }

    public AlgoFrame() {
        this("WELCOME", 512, 512);
    }

    public void start() {

        new Thread(() -> {
            while ( true ) {
                Utils.sleep(200);
                repaint();
            }
        }).start();
    }

    private static class AlgoPanel extends JPanel {

        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = Utils.init(g);
//            g2.
        }

        @Override
        public Dimension getPreferredSize() {
            return super.getPreferredSize();
        }
    }

}
